<template>
	<view class="pl30 pt30 pr30">
		<u-empty text="暂无数据" mode="list" v-if="list.length<1"></u-empty>
		<u-grid :col="4" :border='false' v-else>
			<u-grid-item v-for="(item,i) in list" :key='i' bg-color='#F5F5F5' @click="$jump('/subpkg/goodsList/goodsList?id='+item.id+'&title='+item.title)">
				<image :src="item.pic" class="w150 h150 mb20" ></image>
				<text>{{item.title}}</text>
			</u-grid-item>
		</u-grid>
	</view>
</template>

<script>
	export default {
		onLoad(opt) {
			console.log(opt)
			this.id=opt.id
			uni.setNavigationBarTitle({
			    title: opt.title
			});
			//获取分类列表
			this.getCategorySon()
		},
		data() {
			return {
				id:'',
				list:[]
			};
		},
		methods:{
			getCategorySon() {
				if(this.id) {
					this.$api.categorySon({id:this.id}).then(res=>{
						console.log(res)
						this.list=res.data
					})
				}
			}
		}
	}
</script>

<style lang="scss">
.goodsItem {
	width: 22%;
}
</style>
